package com.boss.sever;

/**
 * 消息处理器工厂，根据消息内容创建相应的消息处理器实例
 * @author 郑炆杰
 */
public class MessageHandlerFactory {
    private MessageHandlerFactory() {
        // 私有构造方法，防止外部实例化
    }

    public static final String COMMAND_SEND = "send";
    public static final String COMMAND_SHOW = "show";

    public static AbstractMessageHandler createHandler(Server server, String clientId, String message) {
        if (message.startsWith(COMMAND_SEND)) {
            return new SendFileHandler(server, clientId, message);
        } else if (message.startsWith(COMMAND_SHOW)) {
            return new ShowFileHandler(server, clientId, message);
        } else {
            return new BroadcastMessageHandler(server, clientId, message);
        }
    }
}

